# -*- coding:utf-8 -*-
# transform the result data


from  builtins import range
from ctypes import *
import numpy as np
from satProp import *
import scipy.io

datafiledfolder = './data/ECI/'


for sat in range(1,25):
    satstr    =  '%02d'% sat
    satfilenameCache = datafiledfolder+ 'Sat'+ satstr+'.npy'
    filesname = 'BDSim_Sat'+str(sat)+'_ECI.txt'
    f         = open(datafiledfolder+filesname,'r')
    filedata   =  f.read().splitlines()
    f.close()
	
    fdata     = []
    for aline in filedata:
        tmpstrlist = aline.split()
        date  = tmpstrlist[0]
        time  = tmpstrlist[1]
        datelist = date.split('-')
        year  =int(datelist[0])
        month =int(datelist[1])
        day   =int(datelist[2])
        timelist = time.split(':')
        hour     =int(timelist[0])
        minute   =int(timelist[1])
        sec  =float(timelist[2])
        timetag = JD2Time([year,month,day,hour,minute,sec]) 
        linedata = [timetag]
        for i in range(2,8):
            linedata.append(float(tmpstrlist[i]))
        fdata.append(linedata)
    fdata  = np.array(fdata,dtype=float)
    np.save(satfilenameCache,fdata)
    scipy.io.savemat(datafiledfolder+str(sat)+'.mat', {'timeTrueTags':fdata[:,0],'kineTrueState':fdata[:,1:7]})
